package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout.LayoutParams;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.framework.widget.RoundCornerLayout;
import com.huawei.appmarket.service.store.awk.bean.SubstanceVideoCardBean;
import com.huawei.appmarket.support.video.VideoPlayer;
import o.azb;
import o.cgz;
import o.Logger;
import o.epv;
import o.eqx;
import o.evp.b;
import o.evt;
import o.ewm.j;

public class SubstanceVideoCard extends BaseDistCard {
    private RoundCornerLayout ʻ;
    private VideoPlayer ˋ;
    private SubstanceVideoCardBean ॱॱ;

    public SubstanceVideoCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        this.ʻ = (RoundCornerLayout) view.findViewById(j.ˊˡ);
        this.ˋ = (VideoPlayer) view.findViewById(j.ʾﾟ);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if ((cardBean instanceof SubstanceVideoCardBean) && this.ˋ != null) {
            this.ॱॱ = (SubstanceVideoCardBean) cardBean;
            ˏ(this.ॱॱ.ꜞ());
            int i = j.ʿˈ;
            int i2 = j.ʿʿ;
            String str = (String) this.ʻ.getTag(i);
            String str2 = (String) this.ʻ.getTag(i2);
            String ʽ = this.ॱॱ.ʽ();
            String ॱ = this.ॱॱ.ॱ();
            if (!TextUtils.isEmpty(str) && str.equals(ॱ)) {
                return;
            }
            if (TextUtils.isEmpty(str2) || !str2.equals(ʽ)) {
                this.ʻ.setTag(i, ॱ);
                this.ʻ.setTag(i2, ʽ);
                this.ˋ.setVideoBaseInfo(new b().ˎ(this.ॱॱ.ˊ()).ˊ(this.ॱॱ.ʽ()).ˋ(this.ॱॱ.ॱ()).ˏ(this.ॱॱ.ͺˏ()).ॱ(this.ॱॱ.u_()).ʼ(this.ॱॱ.ꓸ()).ᐝ(this.ॱॱ.ꜟ()).ʻ(evt.ˏ(this.ॱॱ.sp_)).ॱॱ(this.ॱॱ.ॱـ()).ॱ());
                eqx.ˎ(this.ˋ.ॱॱ(), this.ॱॱ.ʽ());
            }
        }
    }

    private void ˏ(String str) {
        int indexOf;
        int parseInt;
        float f;
        int ˊ;
        int ˏ;
        int ʻ;
        LayoutParams layoutParams;
        float f2 = 0.75f;
        if (!TextUtils.isEmpty(str) && str.contains("x")) {
            indexOf = str.indexOf("x");
            if (indexOf > 0 && str.length() > indexOf + 1) {
                try {
                    parseInt = Integer.parseInt(str.substring(0, indexOf).trim());
                    indexOf = Integer.parseInt(str.substring(indexOf + 1, str.length()).trim());
                    if (parseInt > 0) {
                        f2 = ((float) indexOf) / ((float) parseInt);
                    }
                    f = f2;
                } catch (NumberFormatException e) {
                    Logger.e("substanceVideoCard", e.toString());
                }
                parseInt = this.ॱॱ.ㆍ();
                ˊ = azb.ˊ(this.ʼॱ);
                ˏ = azb.ˏ(this.ʼॱ);
                ʻ = epv.ʻ(this.ʼॱ);
                layoutParams = (LayoutParams) this.ʻ.getLayoutParams();
                if (parseInt != 0) {
                    layoutParams.setMargins(ˊ, 0, ˏ, 0);
                    this.ʻ.setRadius(ʻ);
                    if (azb.ˎ(this.ʼॱ)) {
                        parseInt = (azb.ॱ(this.ʼॱ) - ˊ) - ˏ;
                    } else {
                        parseInt = (epv.ॱ(this.ʼॱ) - ˊ) - ˏ;
                    }
                } else {
                    this.ʻ.setRadius(0);
                    if (azb.ˎ(this.ʼॱ)) {
                        parseInt = azb.ॱ(this.ʼॱ);
                    } else {
                        parseInt = epv.ॱ(this.ʼॱ);
                    }
                }
                indexOf = (int) (f * ((float) parseInt));
                layoutParams.width = parseInt;
                layoutParams.height = indexOf;
                this.ʻ.setLayoutParams(layoutParams);
            }
        }
        f = 0.75f;
        parseInt = this.ॱॱ.ㆍ();
        ˊ = azb.ˊ(this.ʼॱ);
        ˏ = azb.ˏ(this.ʼॱ);
        ʻ = epv.ʻ(this.ʼॱ);
        layoutParams = (LayoutParams) this.ʻ.getLayoutParams();
        if (parseInt != 0) {
            this.ʻ.setRadius(0);
            if (azb.ˎ(this.ʼॱ)) {
                parseInt = epv.ॱ(this.ʼॱ);
            } else {
                parseInt = azb.ॱ(this.ʼॱ);
            }
        } else {
            layoutParams.setMargins(ˊ, 0, ˏ, 0);
            this.ʻ.setRadius(ʻ);
            if (azb.ˎ(this.ʼॱ)) {
                parseInt = (epv.ॱ(this.ʼॱ) - ˊ) - ˏ;
            } else {
                parseInt = (azb.ॱ(this.ʼॱ) - ˊ) - ˏ;
            }
        }
        indexOf = (int) (f * ((float) parseInt));
        layoutParams.width = parseInt;
        layoutParams.height = indexOf;
        this.ʻ.setLayoutParams(layoutParams);
    }
}
